import sys
from PyQt6.QtCore import Qt,QTimer,QPoint
from PyQt6.QtGui import QPixmap
from PyQt6.QtWidgets import QApplication,QWidget,QLabel,QMenu,QWidgetAction


SLEEPING = False
PLAYING = False
def feedCallback():
    print('喂食')

def playCallback():
    global SLEEPING
    global PLAYING
    if SLEEPING:
        pass
    elif not PLAYING:
        print('玩耍')
        PLAYING = True
    else:
        print('停止玩耍')
        PLAYING = False
def sleepCallback():
    global SLEEPING
    global PLAYING
    if not SLEEPING:
        print('睡觉')
        if PLAYING:
            PLAYING = False
        SLEEPING = True
    else:
        print('起床')
        SLEEPING = False
    

class DesktopPetWidget(QWidget):
    def __init__(self):
        super().__init__()
        # 保持在最顶层
        self.setWindowFlags(
            Qt.WindowType.FramelessWindowHint | Qt.WindowType.WindowStaysOnTopHint
            )
        # self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)

        self.setGeometry(100,100,320,320)
        
    def initUI(self):
        pass
    
    def updateFrame(self):
        pass
    def contextMenuEvent(self, event):
        menu = QMenu(self)

        menu.addAction("喂食",feedCallback)
        if not PLAYING:
            menu.addAction("玩耍",playCallback)
        else:
            menu.addAction("停止玩耍",playCallback)
        if not SLEEPING:
            menu.addAction("睡觉",sleepCallback)
        else:
            menu.addAction("停止睡觉",sleepCallback)
        menu.addAction("退出",self.close)
        menu.exec(event.globalPos())


if __name__ == '__main__':
    app = QApplication(sys.argv)
    widget = DesktopPetWidget()
    widget.show()
    sys.exit(app.exec())